<script>
import {querCheckItems} from '@/api/medical_technology/medical_technology'
import  CheckApplyDetail from '@/views/business/medical_technology/check_apply_detail.vue'
export default {
  nane: 'RegistFee',
  components:{
    // CheckApplyDetail:CheckApplyDetail
    CheckApplyDetail
  },
  data() {
    return {
      visable:false,
      itemId:null,
      type:'edit',
      searchForm: {
        registId: null
      },
      //根据患者Id查询的患者信息
      regist: {
        name: '',
        age: null
      },
      //检查的项目,
      checkApplyItems: [
        // {name: 'ct', price: 50, status: 1,},
        // {name: 'ct1', price: 50, status: 2},
        // {name: 'ct2', price: 50, status: 1},
        // {name: 'ct3', price: 50, status: 3},
        // {name: 'ct4', price: 50, status: 4},
      ],
      //检验的项目,
      inspectApplyItems: [
        // {name: '血常规', fee: 50, status: 1,},
        // {name: '尿常规', fee: 50, status: 2},
      ],


    }
  },

  methods: {
    search() {

      querCheckItems(this.searchForm.registId).then(res => {
        if(!res.register){
          this.$message.warning("未查询到患者信息");
          return;
        }
        this.regist = res.register;

        this.checkApplyItems = res.checkApplyItems;
      })
    },
    handlerDeal(itemId,type){
      this.type = type;
      this.itemId = itemId;
      this.visable = true;
    },
    close(){
        this.search();
    }

  }

}
</script>


<template>
  <div class="container">
    <el-form :model="searchForm" ref="queryForm" size="small" :inline="true" label-width="68px">
      <el-form-item label="病历号" prop="registId">
        <el-input v-model="searchForm.registId" placeholder="请输入病历号" clearable/>
      </el-form-item>


      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="search">查询</el-button>
      </el-form-item>
    </el-form>

    <hr/>
    <el-form :model="regist" size="small" :inline="true" label-width="68px">
      <el-form-item label="患者姓名" prop="name">
        <el-input v-model="regist.name" clearable readonly/>
      </el-form-item>
      <el-form-item label="年龄" prop="name">
        <el-input v-model="regist.age" clearable readonly/>
      </el-form-item>


    </el-form>
    <hr/>

    <el-table :data="checkApplyItems" width="100%" size="mini"  stripe   border >
      <el-table-column type="index" label="序号" align="center" ></el-table-column>
      <el-table-column prop="name" label="项目名称(检查、检验)" align="center"></el-table-column>
      <el-table-column prop="price" label="费用" align="center"></el-table-column>
      <el-table-column label="状态" align="center">
        <template slot-scope="scope">

          <el-tag v-if="scope.row.status==1" type="danger">
            待缴费
          </el-tag>
          <el-tag v-else-if="scope.row.status==2" type="success">
            已缴费
          </el-tag>
          <el-tag v-else-if="scope.row.status==3" type="warning">
            退费
          </el-tag>
          <el-tag v-else-if="scope.row.status==4" type="info">
            已完成
          </el-tag>

          <el-tag v-else>
            待提交
          </el-tag>
        </template>

      </el-table-column>

      <el-table-column label="处理" align="center" width="200px">
        <template slot-scope="scope">

          <el-button v-if="scope.row.status==2" type="primary" size="mini" @click="handlerDeal(scope.row.itemId,'edit')">
            处理
          </el-button>


          <el-button v-if="scope.row.status==4" type="success"  size="mini"  @click="handlerDeal(scope.row.itemId,'show')">
            详情
          </el-button>


        </template>
      </el-table-column>

    </el-table>

      <el-dialog :visible.sync="visable"  title="项目详情">
        <CheckApplyDetail :visible.sync="visable" v-if="visable" :itemId="itemId" @close="close" :type="type"></CheckApplyDetail>
      </el-dialog>
  </div>


</template>


<style scoped>
.container {
  margin: 20px 20px
}
</style>
